package org.jeecg.modules.logistics.dictionaries.qz_dic.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.modules.logistics.dictionaries.qz_dic.entity.QzDicInfo;
import org.jeecg.modules.logistics.dictionaries.qz_dic.service.IQzDicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @Info:
 * @Author: 唐小尊
 * @Date: 2019/12/24  10:55
 * @Version: V1.0
 */
@Slf4j
@Api(tags = "求助全部信息")
@RestController
@RequestMapping("/my/qz_dic")
public class QzDicController {
    @Autowired
    IQzDicService qzDicService;

    @AutoLog(value = "得到全部的求助分类字典")
    @ApiOperation(value = "得到全部的求助分类字典", notes = "得到全部的求助分类字典")
    @GetMapping(value = "/getQzDicInfo")
    public Result<QzDicInfo> getQzDicInfo() {
        Result<QzDicInfo> result = new Result<QzDicInfo>();
        QzDicInfo clDicInfoList = qzDicService.getQzDicInfo();
        result.setResult(clDicInfoList);
        result.setSuccess(true);
        return result;
    }

    /**
     * @param json 格式为，dic中放的是操作的数据类型，data中放的是传来的对象，需要操作的对象或者id
     * @return
     */
    @AutoLog(value = "更改某个求助分类字典")
    @ApiOperation(value = "更改某个求助分类字典", notes = "更改某个求助分类字典")
    @PutMapping(value = "/putQzDicInfo")
    public Result putQzDicInfo(@RequestBody String json) {
        Result result = new Result();
        int res = qzDicService.putQzDicInfo(json);
        if (res==0){
            result.setSuccess(false);
        }else {
            result.setSuccess(true);
        }
        return result;
    }

    /**
     * @param json 格式为，dic中放的是操作的数据类型，data中放的是传来的对象，需要操作的对象或者id
     * @return
     */
    @AutoLog(value = "删除一个求助分类字典")
    @ApiOperation(value = "删除一个求助分类字典", notes = "删除一个求助分类字典")
    @DeleteMapping(value = "/delQzDicInfo")
    public Result delQzDicInfo(@RequestBody String json) {
        Result result = new Result();
        int res = qzDicService.delQzDicInfo(json);
        if (res==0){
            result.setSuccess(false);
        }else {
            result.setSuccess(true);
        }
        return result;
    }

    /**
     *
     * @param json 格式为，dic中放的是操作的数据类型，data中放的是传来的对象，需要操作的对象或者id
     * @return
     */
    @AutoLog(value = "添加一个求助分类字典")
    @ApiOperation(value = "添加一个求助分类字典", notes = "添加一个求助分类字典")
    @PostMapping(value = "/addQzDicInfo")
    public Result addQzDicInfo(@RequestBody String json) {
        Result result = new Result();
        int res = qzDicService.addQzDicInfo(json);
        if (res==0){
            result.setSuccess(false);
        }else {
            result.setSuccess(true);
        }
        return result;
    }
}
